<template><!--用户管理-->
  <div class="allBox">
    <div class="webPageTitle">用户管理</div>
    <div class="leftTitle">
      <div class="dataTitle">用户列表</div>
      <div style="float: right;width: 180px" class="myFromBox">
        <Input v-model="queryUname"  placeholder="请输入相关账户名">
        <Button slot="append" icon="ios-search" @click="selectData(1)"></Button>
        </Input>
      </div>
      <div style="float: right;width: 180px" class="myFromBox">
        <Input v-model="queryId"  placeholder="请输入相关用户ID">
        <Button slot="append" icon="ios-search" @click="selectData(1)"></Button>
        </Input>
      </div>
      <div style="float: right;width: 180px" class="myFromBox">
        <Input v-model="queryMobile"  placeholder="请输入相关电话号码">
        <Button slot="append" icon="ios-search" @click="selectData(1)"></Button>
        </Input>
      </div>
      <div style="float: right;" class="myFromBox">
        <DatePicker  @on-clear="clearTime('USER')"  type="datetimerange"  format="yyyy年MM月dd日"
                     placement="bottom-end" placeholder="请选择日期" v-model="searchTime"  @on-ok="clickTime('USER')"
                     style="width: 240px"></DatePicker>
      </div>
      <div style="float: right;" class="myFromBox">
        <Select v-model="queryRole"  style="width:150px"  @on-change="selectData(1)" placeholder="全部">
          <Option v-for="item in roleItem" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
      </div>
    </div>
    <div style="float: left;width: 100%;">
      <Table highlight-row :loading="loading"  :columns="tableColumns" :data="tableData" ></Table>
    </div>

    <div  class="pageBox" >

      <Page :total="total" :page-size="rows" show-total @on-change="selectData" class="pageStyle"></Page>

    </div>
      <!--修改用户类型-->
      <template>
        <Modal
          v-model="updateButtom"
          title="修改用户角色"
          @on-ok="updateData"
          @on-cancel="">
          <p style="margin-top: 10px;font-size: 14px">用户编号：</p>
          <Input v-model="newData.userId" size="large" disabled></Input>
          <p style="margin-top: 10px;font-size: 14px">请选择用户角色<span style="color: red;font-size: 12px;">（不能为空）</span>：</p>
          <template>
            <Select v-model="typeId" style="width:200px;margin-top: 10px;">
              <Option v-for="item in uType" :value="item.value" :key="item.value">{{ item.label }}</Option>
            </Select>
          </template>
        </Modal>
      </template>
      <!--修改用户状态-->
      <template>
        <Modal
          v-model="updateStatue"
          title="修改用户状态"
          @on-ok="updateFunStatus"
          @on-cancel="">
          <p style="margin-top: 10px;font-size: 14px">用户ID：<span style="font-size: 20px">{{newStu.userId}}</span></p>
          <!--状态为 有效-->
          <div v-if="newStu.userStatus  == '有效'">
            <p style="margin-top: 10px;font-size: 14px">当前用户状态：<span style="color: green;font-size: 18px">{{newStu.userStatus}}</span></p>
            <p style="margin-top: 10px;font-size: 14px">修改后用户状态：<span  style="color: red;font-size: 18px">冻结</span></p>
          </div>
          <!--状态为 冻结-->
          <div v-else>
            <p style="margin-top: 10px;font-size: 14px">当前用户状态：<span style="color: red;font-size: 18px">{{newStu.userStatus}}</span></p>
            <p style="margin-top: 10px;font-size: 14px">修改后用户状态：<span  style="color: green;font-size: 18px">有效</span></p>
          </div>
          <p style="margin-top: 10px;font-size: 14px">点击确认进行修改！</p>
        </Modal>
      </template>
      <!--确认重置交易密码-->
      <Modal v-model="resetBut" width="360">
        <p slot="header" style="color:#f60;text-align:center">
          <Icon type="information-circled"></Icon>
          <span>重置密码</span>
        </p>
        <div style="text-align:center;font-size: 14px">
          <p>此用户码重置后将要重新登录！</p>
          <p>是否继续重置密码？</p>
        </div>
        <div slot="footer">
          <Button type="error" size="large" long   @click="resetPwd()">重置</Button>
        </div>
      </Modal>

      <!--读取API错误-->
      <template>
        <Modal v-model="redAPIModal" width="360">
          <p slot="header" style="color:#f60;text-align:left">
            <Icon type="information-circled"></Icon>
            <span>{{redAPIModalTit}}</span>
          </p>
          <div style="text-align:left">
            <p>错误信息：</p>
            <p>{{redAPIModalCen}}</p>
          </div>
          <div slot="footer">
            <Button type="error" size="large" long  @click="redAPIModalFun">确定</Button>
          </div>
        </Modal>
      </template>

      <!--查看用户资产-->
      <template>
        <Modal v-model="showUserCoin" title="查看用户资产" width="60%" >
          <div class="myFromBox">
            <Select v-model="selectCoinType"  style="width:150px"  @on-change="getUserCoinList(1)" placeholder="全部">
              <Option v-for="item in coinTypeList" :value="item.value" :key="item.value">{{ item.label }}</Option>
            </Select>
          </div>
          <div style="height: 550px">
            <div style="float: left;width: 100%;">
              <Table highlight-row :loading="loading"  :columns="userCoinColumns" :data="userCoinData" ></Table>
            </div>
          </div>
          <div slot="footer"></div>
        </Modal>
      </template>


      <!--查看用户发帖-->
      <template>
        <Modal v-model="showUserPost" title="查看用户发帖" width="60%" >
          <div style="height: 550px">
              <div style="float: left;width: 100%;">
                <Table highlight-row :loading="loading"  :columns="userPostColumns" :data="userPostData" ></Table>
              </div>
              <Page :total="showTotal" :page-size="showRows" show-total @on-change="getUserPostList" class="pageStyle"></Page>
          </div>
          <div slot="footer"></div>
        </Modal>
      </template>


    <!--查看用户评论-->
    <template>
      <Modal v-model="showUserComment" title="查看用户评论" width="60%" >
        <div style="height: 550px">
          <div style="float: left;width: 100%;">
            <Table highlight-row :loading="loading"  :columns="userCommentColumns" :data="userCommentData" ></Table>
          </div>
          <Page :total="showTotal" :page-size="showRows" show-total @on-change="getUserCommentList" class="pageStyle"></Page>
        </div>
        <div slot="footer"></div>
      </Modal>
    </template>

    <!--查看帖子内容-->
    <template>
      <Modal v-model="showUserPostContent" title="查看帖子内容" width="40%"  >
        <div style="height: auto;width: 100%" class="userPostContent" v-html="userPostContent" >
        </div>
        <div slot="footer"></div>
      </Modal>
    </template>


    <!--查看用户交易明细-->
    <template>
      <Modal v-model="showUserTrade" title="查看用户交易明细" width="60%" >
        <div class="myFromBox">
          <Select v-model="selectOrderType"  style="width:150px"  @on-change="getUserTradeList(1)" placeholder="全部">
            <Option value="" >全部</Option>
            <Option value="BUY" >买入</Option>
            <Option value="SALE">卖出</Option>
          </Select>
          <Select v-model="selectCoinTypeTrade"  style="width:150px"  @on-change="getUserTradeList(1)" placeholder="全部">
            <Option v-for="item in coinTypeList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          <DatePicker  @on-clear="clearTime('TRADE')"  type="datetimerange"  format="yyyy年MM月dd日"  placement="bottom-end"
                       placeholder="请选择日期" v-model="selectStartEndTm"  @on-ok="clickTime('TRADE')" style="width: 240px"></DatePicker>
        </div>

        <div style="height: 550px">
          <div style="float: left;width: 100%;">
            <Table highlight-row :loading="loading"  :columns="userTradeColumns" :data="userTradeData" ></Table>
          </div>
          <Page :total="showTotal" :page-size="showRows" show-total @on-change="getUserTradeList" class="pageStyle"></Page>
        </div>
        <div slot="footer"></div>
      </Modal>
    </template>


    <!--查看用户充提币明细-->
    <template>
      <Modal v-model="showUserRW" title="查看用户充提币明细" width="60%">
        <div class="myFromBox">

          <Select v-model="selectRW"  style="width:150px"  @on-change="getUserRWList(1)" placeholder="全部">
            <Option value="" >全部</Option>
            <Option value="1" >充币</Option>
            <Option value="2">提币</Option>
          </Select>
          <Select v-model="selectCoinTypeRW"  style="width:150px"  @on-change="getUserRWList(1)" placeholder="全部">
            <Option v-for="item in coinTypeList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          <DatePicker  @on-clear="clearTime('RW')"  type="datetimerange"  format="yyyy年MM月dd日"  placement="bottom-end"
                       placeholder="请选择日期" v-model="selectStartEndTm"  @on-ok="clickTime('RW')" style="width: 240px"></DatePicker>
        </div>

        <div style="height: 550px">
          <div style="float: left;width: 100%;">
            <Table highlight-row :loading="loading"  :columns="userRWColumns" :data="userRWData" ></Table>
          </div>
          <Page :total="showTotal" :page-size="showRows" show-total @on-change="getUserRWList" class="pageStyle"></Page>
        </div>
        <div slot="footer"></div>
      </Modal>
    </template>



  </div>
</template>




<script>
  export  default {
    data(){
      return{
        optionTime:{
          disabledDate(date){
            return date  && date.valueOf() > Date.now() ;
          }
        },
        resetBut:false,
        updateStatue:false,
        updateButtom:false ,                                      //修改控制按钮
        queryUname:'',
        queryMobile:'',
        queryLast:'',
        queryType:'',                                             //要查询的字段
        queryKey:'',
        queryId:'',
        queryRole:'',
        //每页条数
        showPage:1,
        showRows:10,                                                     //每页条数
        showTotal:0,                                                  //总数量
        showUserId : '',

        selectCoinType : '',
        selectCoinTypeTrade : '',
        selectCoinTypeRW : '',
        selectTradeStatus : '',
        selectStartEndTm : '',
        selectOrderType : '',
        selectRW : '',
        coinTypeList : [],

        userCoinData : [],
        userCoinColumns : [
          {title:'币种',key:'coinType',align:'center'},
          {title:'金额',key:'valueDouble',align:'center'},
          {title:'冻结金额',key:'lockValueDouble',align:'center'},
          {title:'状态',key:'statusTxt',align:'center'},
          {title:'是否可以进行交易',key:'isTradeTxt',align:'center'}
        ],

        userRWData : [],
        userRWColumns : [
          {title:'序号',type: 'index5', width: 60, align: 'center',render: (h, params) => {
              return h('span', params.index + (this.showPage- 1) * this.showRows + 1);
            }},
          {title:'类型',key:'opType',align:'center'},
          {title:'币种',key:'coinType',align:'center'},
          {title:'数量',key:'valueDouble',align:'center'},
          {title:'手续费',key:'feeDouble',align:'center'},
          {title:'状态',key:'status',align:'center'},
          {title:'创建时间',key:'createTm',align:'center'},
        ],

        userTradeData : [],
        userTradeColumns : [
          {title:'序号',type: 'index4', width: 60, align: 'center',render: (h, params) => {
              return h('span', params.index + (this.showPage- 1) * this.showRows + 1);
            }},
          {title:'类型',key:'wtTypeTxt',align:'center'},
          {title:'股票名',key:'stockName',align:'center'},
          {title:'委托价',key:'wtAmt',align:'center'},
          {title:'成交价',key:'passAmt',align:'center'},
          {title:'成交数量',key:'passNumDouble',align:'center'},

          {title:'成交成本',key:'passCbSum',align:'center'},
          {title:'成本价',key:'passCbPrice',align:'center'},

          // {title:'成交时间',key:'passTm',align:'center'},
          {title:'委托状态',key:'wtStatusTxt',align:'center'},
          {title:'创建时间',key:'createTm',align:'center'},
        ],

        userPostContent : '',
        userPostData:[],
        userPostColumns:[
          {title:'序号',type: 'index3', width: 60, align: 'center',render: (h, params) => {
              return h('span', params.index + (this.showPage- 1) * this.showRows + 1);
            }},
          {title:'发帖标题',key:'title',align: 'center'},
          {title:'发帖时间',key:'createTm',align: 'center'},
          {title:'发帖内容',align: 'center', render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.showPostContent(params.row.content)
                    }
                  }
                }, '查看详情'),
              ]);
            }},
          //{title:'发帖内容',key:'content',align: 'center' ,type:'html'},
          {title:'操作',align:'center',
            render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.deleteUserPostData(params.row.id,params.row.userId,params.row.commonId)
                    }
                  }
                }, '删除'),
              ]);
            }}
        ],

        userCommentData:[],
        userCommentColumns:[
          {title:'序号',type: 'index2', width: 60, align: 'center',render: (h, params) => {
              return h('span', params.index + (this.showPage- 1) * this.showRows + 1);
            }},
          {title:'评论帖子',align: 'center', render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.showPostContent(params.row.postContent)
                    }
                  }
                }, params.row.postTitle),
              ]);
            }},
          {title:'评论时间',key:'createTm',align: 'center'},
          {title:'评论内容',key:'content',align: 'center'},
          {title:'操作',align:'center',
            render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.deleteUserCommentData(params.row.postId,params.row.userId,params.row.id)
                    }
                  }
                }, '删除'),
              ]);
            }}
        ],




        roleItem:[
          {
            value:'',
            label:'全部'
          },
          {
            value:'0',
            label:'系统用户',
          },
          {
            value:'1',
            label:'运营人员',
          },
          {
            value:'2',
            label:'席位商',
          },
          {
            value:'3',
            label:'财务人员',
          },
          {
            value:'4',
            label:'预留',
          },
          {
            value:'5',
            label:'普通用户',
          },
        ],
        tableColumns:[
          {title:'序号',type: 'index1', width: 60, align: 'center',render: (h, params) => {
              return h('span', params.index + (this.pageUser- 1) * this.rows + 1);
            }},
          {title:'用户ID',key:'userId',align: 'center'},
          {title:'账户名',key:'userName',align: 'center'},
          {title:'用户角色',key:'userType',align: 'center'},
          {title:'用户状态',key:'userStatus',align: 'center'},
          {title:'电话号码',key:'mobile',align:'center'},
          {title:'创建时间',key:'createTm',align:'center',width:130},
          {title:'实名认证',key:'authSatuts',align:'center'},
          {title:'用户资产',align:'center',
            render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.openShowWindow(params.row.userId,"ZC");
                    }
                  }
                }, '明细'),
              ]);
           }},
          {title:'发帖',align:'center',
            render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.openShowWindow(params.row.userId,"POST");
                    }
                  }
                }, params.row.bbsPostCounts),
              ]);
           }},
          {title:'评论',align:'center',
            render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.openShowWindow(params.row.userId,"COMMONT");
                    }
                  }
                }, params.row.bbsCommontCounts),
              ]);
            }},
          {title:'用户充值',key:'rechage',align:'center',
            render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.openShowWindow(params.row.userId,"RW");
                    }
                  }
                }, '明细'),
              ]);
            }},
          {title:'用户交易',align:'center',
            render : (h,params) => {
              return h('div', [
                h('a', {
                  style:{
                    "color" : "red",
                    'text-decoration': 'underline'
                  },
                  on: {
                    click: () => {
                      this.openShowWindow(params.row.userId,"TRADE");
                    }
                  }
                }, '明细'),
              ]);
            }},
          {
            title: '操作',
            key: 'action',
            width: 300,
            align: 'center',
            render: (h, params) => {
              return h('div', [
                h('Button', {
                  props: {
                    type: 'warning',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.showupdate(params.row)
                    }
                  }
                }, '设置角色'),
                h('Button', {
                  props: {
                    type: 'warning',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      /*this.showupdate(params.row)*/
                      this.showPopStatus(params.row);
                    }
                  }
                }, '修改状态'),
                h('Button', {
                  props: {
                    type: 'error',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      /*重置按钮*/
                      this.resetData = params.row;
                      this.resetBut=true;

                      //this.resetPwd(params.row.userName)
                    }
                  }
                }, '重置交易密码')
              ]);
            }
          }
        ],                                        //表构造
        tableData:[],                                            //数据
        /*分页*/
        status:'',                                                  //状态
        rows:10,                                                     //每页条数
        total:0,                                                  //总数量
        loading:true,                                              //表单数据加载时
        newStu:[],
        typeId:'',
        newData:[],
        resetData:'',
        uType:[
          {
            value:'0',
            label:'系统用户',
          },
          {
            value:'1',
            label:'运营人员',
          },
          {
            value:'2',
            label:'席位商',
          },
          {
            value:'3',
            label:'财务人员',
          },
          {
            value:'4',
            label:'预留',
          },
          {
            value:'5',
            label:'普通用户',
          },
        ],
        pageUser:1,
        redAPIModal:false,
        redAPIModalTit:'',
        redAPIModalCen:'',
        searchTime:'',

        showUserCoin:false,
        showUserPost : false,
        showUserPostContent : false,
        showUserComment : false,
        showUserTrade : false,
        showUserRW : false,
      }
    },
    methods:{

      showPopStatus:function (obj) {
        var _self = this;
        _self.updateStatue =  true;
        _self.newStu = obj
      },
      /*打开*/
      showupdate:function (obj) {
        var _self = this;
        _self.updateButtom=true;                                     //修改控制按钮
        _self.newData = obj
      },
      /*读取数据*/
      selectData: function (page) {
        this.pageUser= page
        var _self = this;
        let start = this.searchTime[0]
        let end = this.searchTime[1]
        _self.$http.get(_self.service + '/newuser/pagelist',{params:{
          page:page,
          rows:_self.rows,
          userName:_self.queryUname,
          startTime:start,
          endTime:end,
          userId:_self.queryId,
          userType:_self.queryRole,
          mobile:_self.queryMobile
        }}).then(function (res) {
          if(res.data.code == '001'){
            var datas =  res.data.result.data;
            if(datas != undefined){
              for(var i =0;i<datas.length;i++){
                if(datas[i].userType == 0){
                  datas[i].userType = '系统用户'
                }else if(datas[i].userType == 1){
                  datas[i].userType = '运营人员'
                }else if(datas[i].userType == 2){
                  datas[i].userType = '席位商'
                }else if(datas[i].userType == 3 ){
                  datas[i].userType = '账务人员'
                }else if(datas[i].userType == 4 ){
                  datas[i].userType = '预留'
                }else if(datas[i].userType == 5){
                  datas[i].userType = '普通用户'
                }

                if(datas[i].userStatus == 0){
                  datas[i].userStatus = '冻结'
                }else if(datas[i].userStatus == 1){
                  datas[i].userStatus = '有效'
                }

                if(datas[i].authSatuts == 0){
                  datas[i].authSatuts = '未认证'
                }else if(datas[i].authSatuts == 1){
                  datas[i].authSatuts = '审核中'
                }else if(datas[i].authSatuts == 2){
                  datas[i].authSatuts = '认证通过'
                }else if(datas[i].authSatuts == 3){
                  datas[i].authSatuts = '认证失败'
                }

                let dataTm = new Date(datas[i].createTm)
                let time = _self.formatDate(dataTm,'yyyy-MM-dd hh:mm')
                datas[i].createTm =time;
              }
              _self.tableData = datas;
              _self.total = res.data.result.total;
              _self.loading = false;
            }
          }else{
            _self.modalFun('用户权限信息错误',res.data.msg)
          }
        })

      },
      /*修改用户角色*/
      updateData: function () {
        var _self = this;
        if(this.typeId == ''){
          this.$Notice.warning({
            title: '请选择用户角色！',
          });
          return
        }
        _self.$http.post(_self.service + '/user/userType/update',{
            userType:_self.typeId,
            userId:_self.newData.userId
        }).then(function (res) {
          if(res.data.code == '001'){
            _self.$Message.success("修改成功！");
            _self.selectData(_self.pageUser);
          }else{
            _self.modalFun('修改用户角色错误',res.data.msg)
            _self.selectData(_self.pageUser);
          }
        })

      },
      /*修改用户当前状态*/
      updateFunStatus:function () {
        var _self = this;
        //1:有效    2:冻结
        if(_self.newStu.userStatus == '有效'){
          _self.newStu.userStatus =0
        }else if(_self.newStu.userStatus == '冻结'){
          _self.newStu.userStatus =1
        }
        _self.$http.post(_self.service +'/user/userstatus/update',{
          userStatus:_self.newStu.userStatus,
          userId:_self.newStu.userId
        }).then(function (res) {
          if(res.data.code == '001'){
            _self.$Message.success("修改成功！");
            _self.selectData(_self.pageUser);
          }else{
            _self.modalFun('修改用户当前状态错误',res.data.msg)
          }
        })
      },

      openShowWindow : function(userId,type){
        this.showUserId =userId;
        if(type == 'ZC'){
          //资产
          this.showUserCoin = true;
          this.getCoinTypeList();
          this.getUserCoinList(1);
        }else if(type == 'POST'){
          //发帖
          this.showUserPost = true;
          this.getUserPostList(1);
        }else if(type == 'COMMONT'){
          //评论
          this.showUserComment = true;
          this.getUserCommentList(1);
        }else if(type == 'RW'){
          //充值
          this.showUserRW = true;
          this.getCoinTypeList();
          this.getUserRWList(1);

        }else if(type == 'TRADE') {
          //交易
          this.showUserTrade = true;
          this.getCoinTypeList();
          this.getUserTradeList(1);
        }
      },


      /**==============================发帖===============================**/
      getUserPostList : function (page) {
        var _self = this;
        _self.showPage = page;
        _self.$http.get(_self.service + '/bbspost/list',{params:{
            page:page,
            rows:this.showRows,
            userId:this.showUserId
          }}).then(function (res) {
          if(res.data.code == '001'){
            var datas = res.data.result.data;
            if(datas != undefined){
              for(var i in datas) {
                var dateTM = new Date(datas[i].createTm);
                var tiem = _self.formatDate(dateTM, 'yyyy-MM-dd hh:mm:ss');
                datas[i].createTm = tiem;
              }
              _self.userPostData = datas;
              _self.loading = false;
              _self.showTotal = res.data.result.total
            }
          }else{
            _self.modalFun('读取帖子信息',res.data.msg)
          }
        })
      },

      deleteUserPostData:function (id,userId,commonId) {
        var _self = this;
        var deleteOption = confirm('确定要删除该内容吗？')
        if(deleteOption == false){
          return
        }
        _self.$http.post(_self.service + '/bbspost/invalid',{
          postId:id,
          userId:userId,
          commonId:commonId
        }).then(function (res) {
          if(res.data.code == '001'){
            _self.$Message.success('删除成功！')
          }else{
            _self.modalFun('删除失败',res.data.msg)
          }
          _self.getUserPostList(1);
        })
      },

      /**==============================评论===============================**/
      getUserCommentList:function (page) {
        var _self = this;
        _self.showPage = page;
        _self.$http.get(_self.service + '/common/list',{params:{
            page:page,
            rows:_self.showRows,
            userId : _self.showUserId
          }}).then(function (res) {
          if(res.data.code == '001'){
            var datas = res.data.result.data;
            if(datas != undefined){
              for(var i in datas) {
                var dateTM = new Date(datas[i].createTm);
                var tiem = _self.formatDate(dateTM, 'yyyy-MM-dd hh:mm:ss');
                datas[i].createTm = tiem;
              }
              _self.userCommentData = datas;
              _self.loading = false;
              _self.showTotal = res.data.result.total
            }
          }else{
            _self.modalFun('读取帖子评论信息',res.data.msg)
          }
        })
      },
      deleteUserCommentData:function (postId,userId,commonId) {
        var _self = this;
        var deleteOption = confirm('确定要删除该内容吗？')
        if(deleteOption == false){
          return
        }
        _self.$http.post(_self.service + '/common/invalid',{
          postId:postId,
          userId:userId,
          commonId:commonId
        }).then(function (res) {
          if(res.data.code == '001'){
            _self.$Message.success('删除成功！')
          }else{
            _self.modalFun('删除失败',res.data.msg)
          }
          _self.getUserCommentList(1);
        })
      },

      showPostContent : function(content){
          this.userPostContent =content;
          this.showUserPostContent = true;
      },

      /**=============================用户资产==========================**/
      getUserCoinList:function (page) {
        var _self = this;
        _self.showPage = page;
        _self.$http.get(_self.service +"/coin/user/list",{params:{
            index:page,
            rows:_self.showRows,
            coinType:_self.selectCoinType,
            userIdOrName:_self.showUserId
          }}).then(function (res) {
          if(res.data.code == '001'){
            let tableData = res.data.result.list;
            if(tableData != undefined){
              for(var i in tableData){
                if(tableData[i].isTrade == 0){
                  tableData[i].isTradeTxt = "不可交易"
                }else  if(tableData[i].isTrade == 1){
                  tableData[i].isTradeTxt = "可以交易"
                }

                if(tableData[i].status == 0){
                  tableData[i].statusTxt = "无效"
                }else if(tableData[i].status == 1){
                  tableData[i].statusTxt = "有效"
                }
              }
              _self.userCoinData = tableData;
              _self.loading = false;
              _self.showTotal = res.data.result.total;
            }
          }else{
            _self.modalFun('读取列表信息错误',res.data.msg)
          }
        })
      },

      /**=============================用户交易明细==========================**/
      getUserTradeList:function (page) {
        var _self = this;
        _self.showPage = page;
        _self.$http.get(_self.service + '/trade/order/buysalepage',{params:{
            index:page,
            rows:_self.showRows,
            type:_self.selectOrderType,
            stockCode:_self.selectCoinTypeTrade,
            ipStockCode:'BTE',
            moneyType:'BTC',
            status:_self.selectTradeStatus,
            userId:_self.showUserId,
            startTm : _self.selectStartEndTm[0],
            endTm : _self.selectStartEndTm[1]
          }}).then(function (res) {
          if(res.data.code == '001'){
            var tableData = res.data.result.list;
            if(tableData != undefined){

              for(var i in tableData) {
                var dataTm = new Date(tableData[i].createTm);
                var tiem = _self.formatDate(dataTm, 'yyyy-MM-dd hh:mm');
                tableData[i].createTm = tiem;

                if(tableData[i].wtStatus == 0){
                  tableData[i].wtStatusTxt = '委托成功'
                }
                if(tableData[i].wtStatus == 1){
                  tableData[i].wtStatusTxt = '完全成交'
                }
                if(tableData[i].wtStatus == 2){
                  tableData[i].wtStatusTxt = '部分成交'
                }
                if(tableData[i].wtStatus == 3){
                  tableData[i].wtStatusTxt = '撤单'
                }

                if(tableData[i].wtType == 1){
                  tableData[i].wtTypeTxt = '买入'
                }
                if(tableData[i].wtType == 2){
                  tableData[i].wtTypeTxt = '卖出'
                }
                tableData[i].stockName = tableData[i].stockCode +'/'+tableData[i].moneyType
                tableData[i].passCbSum = tableData[i].passNumDouble * tableData[i].passAmt;
                tableData[i].passCbPrice =  tableData[i].passAmt;
              }
              _self.userTradeData = tableData
              _self.showTotal = parseInt(res.data.result.total);
              _self.loading = false
            }
          }else{
            _self.modalFun('获取委托记录信息错误',res.data.msg)
          }
        })

      },

      /**==============================充提币===============================**/
      getUserRWList:function (page) {
        var _self = this;
        _self.showPage = page;
        _self.$http.get(_self.service + '/coin/userCoinRecord',{params:{
            index:page,
            rows:_self.showRows,
            coinType:_self.selectCoinTypeRW,
            userId : _self.showUserId,
            opType :_self.selectRW,
            startTm : _self.selectStartEndTm[0],
            endTm : _self.selectStartEndTm[1]
          }}).then(function (res) {
          if(res.data.code == '001'){
            var datas = res.data.result.data;
            if(datas != undefined){

              for(var i in datas) {
                var dateTM = new Date(datas[i].createTm);
                var tiem = _self.formatDate(dateTM, 'yyyy-MM-dd hh:mm:ss');
                datas[i].createTm = tiem;
                var status = datas[i].status;
                if(status == 0){
                  status = '未审核';
                }else if(status == 1){
                  status = "提币成功";
                }else if(status == 2){
                  status = '提币失败';
                }else if(status == 3){
                  status = "提币驳回";
                }

                if(datas[i].opType == 1){
                  datas[i].opType = '充币'
                }else if(datas[i].opType == 2){
                  datas[i].opType = '提币'
                }

                datas[i].status = status;
              }
              _self.userRWData = datas;
              _self.loading = false;
              _self.showTotal = parseInt(res.data.result.total);
            }
          }else{
            _self.modalFun('读取提币信息',res.data.msg)
          }
        })
      },


      /**
       * 获取币种下拉列表的数据
       * **/
      getCoinTypeList:function () {
        var _self = this
        _self.$http.get(_self.service + '/coin/onlyCoinList')
          .then(function (res) {
            if(res.data.code == '001'){
              var datas = res.data.result.data
              for(var i in datas){
                datas[i].value = datas[i].coinType;
                datas[i].label = datas[i].coinType;
              }
              datas.unshift({value : "",label : "全部"})
              _self.coinTypeList = datas
            }
          })
      },



      /*获取浏览器高度对 table的 row 显示进行数量控制 */
      tableRowH:function(){
        var _self = this;
        var winHeight = document.documentElement.clientHeight;
        _self.rows = Math.floor((winHeight - (40+50+50+100))/48)-1;
      },
      /*重置交易密码*/
      resetPwd:function () {
        var _self = this;
        var text = ''
        if((_self.resetData.mobile).trim() != ''){
          text = _self.resetData.mobile
        }else{
          text = _self.resetData.userName
        }
        _self.$http.post(_self.service + "/coin/delTradePwd",{
          userName:text
        }).then(function (res) {
            if(res.data.code == '001'){
              _self.$Notice.success({
                title:text + ",交易密码已重置!",
              });
              _self.selectData(_self.pageUser)
              _self.resetBut=false;
            }else {
              _self.$Notice.error({
                title:text+res.data.msg,
              });
              _self.resetBut=false;
            }
        })
      },
      /*Modal弹出层*/
      modalFun:function (modTit,modCen) {
        this.redAPIModal = true;
        this.redAPIModalTit = modTit;
        this.redAPIModalCen = modCen;
      },
      redAPIModalFun:function () {
        this.redAPIModal = false
      },
      /*获取选中日期*/
      clickTime:function (type) {
        if(type == 'TRADE'){
          for(var i in this.selectStartEndTm){
            let dataTm  = new Date(this.selectStartEndTm[i]);
            let time =  this.formatDate(dataTm,'yyyy-MM-dd hh:mm');
            var oldTime = (new Date(time)).getTime();
            this.selectStartEndTm[i] = oldTime
          }
          if(this.selectStartEndTm[0]  == this.searchTime[1]){
            this.selectStartEndTm[1] = this.selectStartEndTm[1]+86400000
          }else{
            this.selectStartEndTm[1] = this.selectStartEndTm[1] + (86400000-1)
          }
          this.getUserTradeList(1)

        }else if(type == 'USER'){
          for(var i in this.searchTime){
            let dataTm  = new Date(this.searchTime[i]);
            let time =  this.formatDate(dataTm,'yyyy-MM-dd hh:mm');
            var oldTime = (new Date(time)).getTime();
            this.searchTime[i] = oldTime
          }
          if(this.searchTime[0]  == this.searchTime[1]){
            this.searchTime[1] = this.searchTime[1]+86400000
          }else{
            this.searchTime[1] = this.searchTime[1] + (86400000-1)
          }
          this.selectData(1)
        }else if(type == 'RW'){
          for(var i in this.selectStartEndTm){
            let dataTm  = new Date(this.selectStartEndTm[i]);
            let time =  this.formatDate(dataTm,'yyyy-MM-dd hh:mm');
            var oldTime = (new Date(time)).getTime();
            this.selectStartEndTm[i] = oldTime
          }
          if(this.selectStartEndTm[0]  == this.searchTime[1]){
            this.selectStartEndTm[1] = this.selectStartEndTm[1]+86400000
          }else{
            this.selectStartEndTm[1] = this.selectStartEndTm[1] + (86400000-1)
          }
          this.getUserRWList(1);
        }

      },
      clearTime:function (type) {
        if(type == 'TRADE' || type == 'RW'){
          this.selectStartEndTm[0] = '';
          this.selectStartEndTm[0] = '';
          this.getUserTradeList(1);
        }else if(type == 'USER'){
          this.searchTime[0] = '';
          this.searchTime[1] = '';
          this.selectData(1)
        }
      }

    },
    created:function(){
      // this.$http.defaults.headers.common['userId'] =this.cookie.getCookie('userId') ;
      // this.$http.defaults.headers.common['ticket'] = this.cookie.getCookie('ticket');
      this.tableRowH();
      this.selectData('1');
    }

  }
</script>
<style>
  .pageBox{
    float: left;
    width: 100%;
    margin-top: 10px
  }
  .pageStyle{
    float: right;
    margin-right: 20px;
    margin-bottom: 10px;
  }
  .userPostContent img{
    max-width: 100%;
  }
</style>
